﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Environment.Extensions.Models;
using Orchard.Security.Permissions;

namespace AwesomeSlider{

    public class Permissions : IPermissionProvider
    {
        public static readonly Permission ManageSliders = new Permission { Description = "Manage sliders", Name = "ManageSliders" };

        public static readonly Permission PublishSliderItem = new Permission { Description = "Publish or unpublish slider item for others", Name = "PublishSliderItem", ImpliedBy = new[] { ManageSliders } };
        public static readonly Permission EditSliderItem = new Permission { Description = "Edit any slider item", Name = "EditSliderItem", ImpliedBy = new[] { PublishSliderItem } };

        public virtual Feature Feature { get; set; }

        public IEnumerable<Permission> GetPermissions()
        {
            return new[] {
                ManageSliders,
                PublishSliderItem
            };
        }

        public IEnumerable<PermissionStereotype> GetDefaultStereotypes()
        {
            return new[] {
                new PermissionStereotype {
                    Name = "Administrator",
                    Permissions = new[] {ManageSliders}
                },
                new PermissionStereotype {
                    Name = "Editor",
                    Permissions = new[] {PublishSliderItem}
                },
            };
        }

    }
}